GRAWP001
REALNAME -Time
IMAGE bcalarmclock.png
SCRIPT
//#CLIENTSIDE

function onCreated() { 
  // Change Environment
  environmentEffect();
  // Begin Looping
  setTimer(0.5);
} 

function onPlayerEnters() {
  // Change Environment
  environmentEffect();
}

function onTimeout() {
  // Change Environment
  environmentEffect();
  // Loop
  setTimer(0.5);
}

function environmentEffect() {
  // Check if on Overworld
  if (player.gmap.name == "playerworld.gmap") {
    // Determine Exact Time
    temp.time = getCurrentHour() + (getCurrentMinutes() / 60);
    // Calculate Alpha Effect
    temp.alpha = limit(1 - (0.7 - cos((temp.time / 23) * (pi * 2)) * 0.5), 0, 0.75);
    // Set Effect
    seteffect(0, 0, 0, temp.alpha);
  }
}

/*
   Time Calculations
*/

public function getCurrentHour() {
  return int(timevar / 60) % 24;
}

public function getCurrentMinutes() {
  return timevar % 60;
}

function limit(val, min, max) {
  return min(max(min, val), max);
}
SCRIPTEND
